Powder Game code
Powder Game codes are used in Powder Game and Powder Game 2 to save what's on-screen as a code. These codes can be then saved in a file or otherwise stored for later use. To get a code, press the "Get" button. To load a code, paste a code into the box and press "Set." The following is an example code, which displays some text written with steam: Here is the same example, but in the modern Powder Game code format: Details for the modern Powder Game code is found below. Data Structure (Powder Game) A Powder Game Get-Set code is comprised of an 8-character header optionally followed by an 8-character extension, followed by a sequence of compressed element and object data, and a 3-character checksum at the end. All data in both games' codes, except where otherwise noted, is encoded in a base 64 numeral system, where each character is a digit representing a value from 0 to 63. The digits, in order, are 0-9, A-Z, a-z, ., and *. Any other characters will be read as zeroes. Header The code's header contains global values such as the BG and Speed settings. Unlike most other parts of the code, these values are not stored as base 64, but instead follow ASCII order starting at '0'. This is only noticeable with the BG value however, as the order of digits after '9' starts with ':' and ';' before progressing into capital letters. Attempting to load a code with any values for header digits other than the ones listed will crash the game. The structure is as follows: The BG values are as follows: Header extension Element and object data This compressed data comprises the majority of a Get-Set code, and it contains every element and object on the screen. It uses a simple dictionary-based compression algorithm with repetition compression as well, and consists of a sequence of 3-character-long units. Each unit consists of a 2-digit dictionary reference followed by one digit of literal data. A dictionary reference points to the location of another unit in the sequence, and is recursive, as that unit can in turn can point to another unit with its own dictionary reference, and so on. Dictionary references start at 01; a dictionary reference of 00 is null and is ignored. To decompress screen data, each unit must be evaluated in sequence. For each unit, its dictionary reference must be evaluated recursively until a null reference is found which ends the reference chain, and then the literal values of every unit in the chain are added to the end of the decompressed output in reverse order. If a literal value x greater than 47 (l) is encountered, it signifies that the literal value directly before it should be repeated x - 48 times. However, if another literal value y also greater than 47 is encountered directly after x, it signifies that x and y together are a reverse-order two-digit number with the value of ((y - 47) * 16) + (x - 47) - 1 and that the value immediately before x should be repeated that many times instead. The result is a sequence of at least 120000 digits (at least one for each pixel in the game field), each of which specifies an element, an object, an attribute, or empty space. Elements or objects such as Fireworks or Players are followed by a second digit specifying their attribute. Some elements such as Clone might seem to have an attribute while the game is running but do not actually save it; these do not show up in the code. Attempting to load a code with any non-base-64 element digits will simply result in those values being read as empty space. However, the two remaining empty spaces for elements, k and l, will crash the game when loaded. Additionally, attempting to load a code with more than 2 Players hacked in will also crash the game. The values corresponding to each element and object are as follows: Checksum The checksum is an encoded 3-digit number at the end of the code that is intended to prevent any corruption or tampering to the code. It is stored as a hexadecimal number in reverse digit order and does not use base 64 encoding. The first digit is a lowercase letter (a-p), the second is an uppercase letter (A-P), and the third is a numeric digit (0-7). Encoded this way, for instance, the checksum 0x507 would become hA5. The maximum value for the checksum is 0x7FF. The checksum can be computed by first adding together the ASCII value of each character in the code multiplied by its position in the code modulo 255. (The position is 1-based, so the first character would be multiplied by 1, the second by 2, etc.) The checksum is then obtained by computing that value modulo 0x7FF. The Get-Set mechanism will reject any code where the computed checksum does not match the checksum value stored in the code. See also *Get-Set, the article about the Get-Set mechanism in general. Category:Powder Game